home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / ellis / gc5.ps (.svg) < prev    next >
Encapsulated PostScript  |  1993-07-23  |  61KB  |  527x888  |  8-bit (127 colors)
Labels: black | darkness
OCR: 10.IInterior pointers Unlikesmostsotherslanguagesswithsgarbagescollection, sthissproposalsforsC++garbage collection allowssinterior pointers, pointerssaddressingsthesmiddlesofsobjects.s(Takingsthesaddresssofsan arrayselementsorsansobject'ssmembersyieldssansinteriorspointer.) Languagesdesignersstypicallysassumesthatsinteriorspointerssmakesgarbagescollection significantlysmoresexpensive.sIfsinteriorspointerssaresallowed,sascollectorscannotsassumes that everyspointersaddressess thesbasesofsansobject,sandsitsmustsmapseveryspointersitsfollowsstosits correspondingsbase. Sincesthatsmappingsoccurssinsthescollector'ssinnersloops, sitsmightscostsasfair bitsextra.sAlso,sallowingsinteriorspointersscanscauses conservatives collectorsstos retainsmore storage. OursinitialsdesignsofsthesC++ssafessubsetsprohibitedsinteriorspointers.sAppendixs spresents thesnecessaryschangesstosthessafessubsetsandsdiscussessthesimplicationssforsimplementations. But weseventuallysdecided thatsitswouldsbesbetterstosallowsinteriorspointers, sforsseveral reasons. First,stosappealstostheslargestsnumbersofsprogrammers,sweswantedstosminimizesrestrictionsson theslanguage.sThoughspracticalssystems sprogrammingslanguagesslikesCedar,sModula-3,sandsAda prohibitsorsdiscouragesinteriorspointers, sweswantedstosavoidsantagonizingsthesmanysC++ programmersswhoswouldssurelysobjectstostheirsabsence. Second, smultiplesinheritancescreatessproblemssnotsfacedsby sotherslanguages.Givensasclasss derivedsfromsclassess sands ,sinscurrentsimplementationsswidenings("up-casting")sasC*stosas* canscreatesansinteriorspointerstosthesstoragesfors sinsidesthes sobject.sThussprohibitingsallsinterior pointersswouldsrequiresradicalschangesstoscurrentsimplementationssofsmultiplesinheritance. Appendixs spresentssasrun-timesrepresentationsofsobjectssthatscouldsefficientlyshandlesthesspecial casesofsinteriorspointerssresultingsfromswideningscasts,sbutsthissschemeswoulds requiresnon-trivial changesstoscurrentsimplementationsskatswesthinkswouldsimpedesacceptancesofsC++sgarbage collection. Third, stwos recentlysdevelopedsfamiliessofspartiallysconservativescollectionsalgorithmsscan handlesinteriorspointerssfairlyscheaplys[Bartletts89,sYips91,sBoehm91,Zorns92],sandswesbelieve thatsthesesalgorithmssbestsmeetsallsthesotherspractical requirementssofsC++garbagescollection (seessections ).sWesthinks thats allowingsgeneralsinteriorspointersswillstypicallyscostslesssthansasfew percentsextrasinstotalsprogramsexecutionstime.s(Seesbelow.) Samples'sslanguagesproposals Samples 92]swouldsfacilitatesmoresefficients followingsofsinterior pointerssbysthescollector.sImplementationsscouldswrapseachscollectedsobject,smembersobject,sand sub-objectswithsasg cewrappersthatswouldsletsthesgarbage collectorsquicklysfinds the soutermost containingsobjectsinsthesheap.Mostslikely,sthesgcswrapperswouldsrequiresnosextrasspacesin objectsswithsvirtualsfunctionssifsasschemeslikesthatsinsappendixs sissused,sbutsobjectsswithout virtualsfunctionsswouldsneedsansextrasheaderswordsinstheirsrepresentation.sThescostsofsfollowing interiorspointerssissonlysreduced, snotseliminated, becausesthesproposalsstillsallowssthes declaration ofsembeddedsobjectssandspointersstossuchsobjects,swithsthesintentions thatsembeddedsobjectssdon't havesgcswrappers;sfollowingsansembeddedspointerswouldsentails thesfullscostsofsmappingsan interiorspointerstosthescorrespondingsobjectsbase.sAssdiscussedsinssections3.5,sSamples'ssproposal doesn'tsmeetsourscriteriasofsminimalschangessandscoexistence. 10.1.nl'herrun-timerostrof interior pointers ThesBoehmsandsBartlettsfamilysofscollectors sprovidesheapsdatasstructures that allowsthescollector tosmapsinteriorspointersstosbasespointers. ThesBoehmscollectorscarvessthesheapsintospages,swith allsofsthesobjectssonsaspagesbeingsthessamessizes("bigsbagsofspages") sandsaspagestablesgivingsthe sizesofsobjectssonseachspage.sThesBartlettscollectorsskeepsasbitsvectorsperspagesindexedsbysword offset, sindicatingsthesbeginningssofsobjectssonsthespage.sInseithersscheme,smappingsaspointerstosa basespointersinvolvessextractingsaspagesindex,sindexingsintosthespagestable,sthensindexingsanother tablesorsasbitsvector. 41